<?php 
namespace app\api\controller;

use app\api\ApiController;
use common\service\AuthService;
use common\service\BotInvService;

class Botinv extends ApiController
{

	public function lists($appId = 730, $page = 1, $limit = 25)
	{
		$steamInfo = AuthService::getInstance()->verifyToken();
		if(empty($steamInfo)){
			return $this->errorMessage(BAD_ACCESS_TOKEN_NO, BAD_ACCESS_TOKEN_ERROR);
		}
		$userId = $steamInfo['user_id'];

		$result = $this->validate(
			[
				'appId' => $appId,
				'page'  => $page,
				'limit' => $limit,
			],
		    [
				'appId' => 'number',
				'page'  => 'number',
				'limit' => 'number',
		    ]
		);

		if (true !== $result) {
			return $this->errorParams($result);
		}

		$list = BotInvService::getInstance()->lists($userId, $appId, $page, $limit);

		return $this->successJson($list);
	}
}